package com.jietuo.class01;

/**
 * @author zhangx & jietuo_zx@163.com
 * @version 1.0
 * @date 2024/3/1
 * @description: 8，如何不用额外变量交换两个数
 * 直接使用异或，异或本质是，相同为0，不同为1，无进位相加。
 */
public class Code08_ExchangeTwoNum {

    public static void main(String[] args) {
        int a = 10;
        int b = 12;
        System.out.println("a = " + a + ",b = " + b);
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
        System.out.println("a = " + a + ",b = " + b);
    }
}
